<?php
function recurse_files($src) {
    $dir = opendir($src);

    while(false !== ( $file = readdir($dir)) ) {
        if (( $file != '.' ) && ( $file != '..' )) {
        	//echo $src."<br>";
            if ( is_dir($src . '/' . $file) ) {
            	
                recurse_files($src . '/' . $file);
            }
            else {
            	//echo $src."/".$file."<br>";
                copy($src . '/' . $file,str_replace("photos","photos1",$src . '/' . $file));
            }
        }
    }
    closedir($dir);
}

recurse_files("images/photos");
?>